package com.zte.claa.inficombo.csa.app.service.sapi.ffhost.bean;

import java.sql.Timestamp;

import com.fasterxml.jackson.annotation.JsonFormat;

public class FFHostPartEvent {
	public static final int EVENT_TP_NORMAL = 0; 	//	正常运行	运行状态值为1
	public static final int EVENT_TP_TEST = 1; 	//	测试	运行状态值为0
	public static final int EVENT_TP_FIRE = 2; 	//	火警	Firestate=1
	public static final int EVENT_TP_FAIL = 3; 	//	故障	Failstate=1
	public static final int EVENT_TP_MASK = 4; 	//	屏蔽	Maskstate=1
	public static final int EVENT_TP_CTRL = 5; 	//	监管	Monistate=1
	public static final int EVENT_TP_START = 6; 	//	启动	Openstate=1
	public static final int EVENT_TP_FEEDBACK = 7; 	//	反馈	Feedbackstate=1
	public static final int EVENT_TP_DELAY = 8; 	//	延时	Delaystate=1
	public static final int EVENT_TP_POWFAIL = 9; 	//	主电故障	Mainpowerstate=1
	public static final int EVENT_TP_OTHER = 10; 	//	其他	预留
	
	private long logid = 0;	//	记录ID	Long	自增长	N	主键
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",  timezone="GMT+8")
	private Timestamp collecttime;	//	采集时间	Timestamp		N	创建索引
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",  timezone="GMT+8")
	private Timestamp reporttime;	//	上报时间	Timestamp		N	创建索引
	
	private String deveui;		//	消防设施系统资源编号	Varchar(100)	NA	N	创建索引 
	private String projectid;	//	项目ID	VARCHAR(200)		N	归属项目，	创建索引 
	private int systype = 0;	//	消防设施系统类型	Int	0	N	参见GB规范定义
	private int sysaddr = 0;	//	消防设施系统地址	Int	0	N	
	private int parttype = 0;	//	消防设施部件类型	Int	0	N	
	private String partaddr;	//	消防设施部件	Varchar(10)	0	N，16进制数字字符串，大写.	
	
	private int eventtype = 0;  //	事件类型	Int
	private String remark; 		//	备注	VARCHAR(100)
	
	public FFHostPartEvent(){
		
	}

	public long getLogid() {
		return logid;
	}

	public void setLogid(long logid) {
		this.logid = logid;
	}

	public Timestamp getCollecttime() {
		return collecttime;
	}

	public void setCollecttime(Timestamp collecttime) {
		this.collecttime = collecttime;
	}

	public String getDeveui() {
		return deveui;
	}

	public void setDeveui(String deveui) {
		this.deveui = deveui;
	}

	public String getProjectid() {
		return projectid;
	}

	public void setProjectid(String projectid) {
		this.projectid = projectid;
	}

	public int getSystype() {
		return systype;
	}

	public void setSystype(int systype) {
		this.systype = systype;
	}

	public int getSysaddr() {
		return sysaddr;
	}

	public void setSysaddr(int sysaddr) {
		this.sysaddr = sysaddr;
	}

	public int getParttype() {
		return parttype;
	}

	public void setParttype(int parttype) {
		this.parttype = parttype;
	}

	public String getPartaddr() {
		return partaddr;
	}

	public void setPartaddr(String partaddr) {
		this.partaddr = partaddr;
	}

	public Timestamp getReporttime() {
		return reporttime;
	}

	public void setReporttime(Timestamp reporttime) {
		this.reporttime = reporttime;
	}

	public int getEventtype() {
		return eventtype;
	}

	public void setEventtype(int eventtype) {
		this.eventtype = eventtype;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
		if(this.remark != null){
			this.remark = this.remark.trim();
		}
	}
	
	public static FFHostPartEvent fromFFHostPartState(FFHostPartState state){
		FFHostPartEvent event = new FFHostPartEvent();
		event.setSysaddr(state.getSysaddr());
		event.setSystype(state.getSystype());
		event.setPartaddr(state.getPartaddr());
		event.setParttype(state.getParttype());
		event.setCollecttime(new Timestamp(System.currentTimeMillis()));
		event.setReporttime(state.getCollecttime());
		event.setDeveui(state.getDeveui());
		event.setEventtype(0);
		event.setProjectid(state.getProjectid());
		event.setRemark(state.getRemark());
		return event;
	}
}
